#include "common.hpp"

int main()
{
    Log log;
    Init fifo;
    int shmid = creatshm();
    char *addr = (char *)shmat(shmid, 0, 0);
    //打开管道
    int fd = open(FIFO_FILE, O_RDONLY);
    shmid_ds ds;
    
    while (true)
    {
        // cout << "processB: " << addr;
        // shmctl(shmid, IPC_STAT, &ds);
        // cout << "size: " << ds.shm_segsz << endl;
        // cout << "attach: " << ds.shm_nattch << endl;
        // cout << "key: 0x" << hex << ds.shm_perm.__key << endl;

        char c = 0;
        ssize_t x = read(fd, &c, 1);
        if (x == 0)
        {
            break;
        }

        cout << "processB:" << addr;
        sleep(1);
    }
    int ret = shmdt(addr);
    shmctl(shmid, IPC_RMID, 0);  
    return 0;
}